home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / doom / quake_ad.zip / HIPQW.ZIP / SRC / WEAPONS.QC < prev    next >
Text File  |  1997-03-13  |  52KB  |  2,322 lines

  1. /*
  2. */
  3. //hip
  4. //JIM
  5. void( vector pos ) placebullethole;
  6. void ()muzzleflash;
  7. float (entity targ) visible;
  8. //hip
  9. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  10. void () player_run;
  11. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  12. void(vector org, float damage) SpawnBlood;
  13. void() SuperDamageSound;
  14.  
  15. //hip
  16.  
  17. //MED 10/18/96
  18. void(float damage) spawn_touchblood;
  19. /*
  20. ================
  21. HIPNOTIC WEAPONS
  22. ================
  23. */
  24. void() HIP_LaserTouch =
  25. {
  26.     local vector org;
  27.    local vector spot1,spot2;
  28.    local vector oldvel;
  29.    local float mag;
  30.    local float r;
  31.  
  32.    self.owner = world;
  33.    self.cnt = self.cnt + 1;
  34.    if (pointcontents(self.origin) == CONTENT_SKY)
  35.     {
  36.         remove(self);
  37.         return;
  38.     }
  39.    oldvel = normalize(self.old_velocity);
  40.    spot1 = self.origin - (16*oldvel);
  41.    spot2 = self.origin + (16*oldvel);
  42.    traceline (spot1, spot2, FALSE, self);  // see through other monsters
  43.    self.origin = trace_endpos;
  44.  
  45.    org = self.origin;
  46.  
  47.     if (other.health)
  48.       {
  49.       if (self.lastvictim == other)
  50.          {
  51.          self.dmg = self.dmg / 2;
  52.          }
  53.       spawn_touchblood (self.dmg);
  54.       T_Damage (other, self, self.lastvictim, self.dmg);
  55.       }
  56.    else if ((self.cnt == 3) || (random()<0.15))
  57.       {
  58.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  59.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  60.         WriteCoord (MSG_BROADCAST, org_x);
  61.         WriteCoord (MSG_BROADCAST, org_y);
  62.         WriteCoord (MSG_BROADCAST, org_z);
  63.       }
  64.    else
  65.       {
  66. //      self.dmg = 0.66 * self.dmg;
  67.       self.dmg = 0.9 * self.dmg;
  68. //      self.speed = 0.95 * self.speed;
  69.       self.velocity = oldvel+(2*trace_plane_normal);
  70.       self.velocity = normalize(self.velocity);
  71.       self.velocity = self.speed * self.velocity;
  72.       self.old_velocity = self.velocity;
  73.       if (self.flags & FL_ONGROUND)
  74.          self.flags = self.flags - FL_ONGROUND;
  75.       r = random();
  76.       sound (self, CHAN_WEAPON, "hipweap/laserric.wav", 1, ATTN_STATIC);
  77. /*
  78.       if (r<0.33)
  79.          sound (self, CHAN_WEAPON, "weapons/ric1.wav", 1, ATTN_STATIC);
  80.       else if (r<0.66)
  81.          sound (self, CHAN_WEAPON, "weapons/ric2.wav", 1, ATTN_STATIC);
  82.       else
  83.          sound (self, CHAN_WEAPON, "weapons/ric3.wav", 1, ATTN_STATIC);
  84. */
  85.       return;
  86.       }
  87.    sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
  88.    remove(self);
  89.  
  90. };
  91. void() HIP_LaserThink =
  92.    {
  93.    local float delta;
  94.  
  95.  
  96.    if (time>self.attack_finished)
  97.       {
  98.       remove(self);
  99.       return;
  100.       }
  101.    if (self.flags & FL_ONGROUND)
  102.       self.flags = self.flags - FL_ONGROUND;
  103.    self.velocity = self.old_velocity;
  104.    self.angles = vectoangles(self.velocity);
  105.    self.nextthink = time+0.1;
  106.    };
  107.  
  108. void(vector org, vector vec, float light) HIP_LaunchLaser =
  109. {
  110. //   sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
  111.    sound (self ,CHAN_WEAPON, "hipweap/laserg.wav", 1, ATTN_NORM);
  112.  
  113.    vec = normalize(vec);
  114.  
  115.     newmis = spawn();
  116.    newmis.owner = self;
  117.    newmis.classname = "hiplaser";
  118.    newmis.lastvictim = self;
  119.    newmis.movetype = MOVETYPE_FLYMISSILE;
  120.    newmis.solid = SOLID_BBOX;
  121.    if (light)
  122.       newmis.effects = EF_DIMLIGHT;
  123.  
  124.    setmodel (newmis, "progs/lasrspik.mdl");
  125.     setsize (newmis, '0 0 0', '0 0 0');
  126.  
  127.     setorigin (newmis, org);
  128.  
  129.    newmis.speed = 1000;
  130.    newmis.dmg = 18;
  131.    newmis.velocity = vec * newmis.speed;
  132.    newmis.old_velocity = newmis.velocity;
  133.    newmis.angles = vectoangles(newmis.velocity);
  134.    newmis.avelocity = '0 0 400';
  135.  
  136.    newmis.nextthink = time;
  137.    newmis.attack_finished = time + 5;
  138.    newmis.think = HIP_LaserThink;
  139.    newmis.touch = HIP_LaserTouch;
  140.    newmis.count = 0;
  141.  
  142. };
  143.  
  144. /*
  145. =================
  146. HIP_FireLaser
  147. =================
  148. */
  149. void(float stat) HIP_FireLaser =
  150.    {
  151.     local vector org;
  152.    local vector dir;
  153.    local vector out;
  154.    local float ofs;
  155.    local float aofs;
  156.  
  157.    if (!self.button0)
  158.       {
  159.       player_run ();
  160.       return;
  161.       }
  162.    if (self.ammo_cells < 1)
  163.       {
  164.         self.weapon = W_BestWeapon ();
  165.         W_SetCurrentAmmo ();
  166.         return;
  167.       }
  168.    SuperDamageSound();
  169.    muzzleflash();
  170.    makevectors (self.v_angle);
  171.  
  172.    ofs = 6;
  173.    out = v_forward;
  174.    out_z = 0;
  175.    out = normalize(out);
  176.    org = self.origin + ((12-ofs) * v_up) + (12*out);
  177. //   org = self.origin + (1*v_forward);
  178.    dir = aim (self, 1000);
  179.    aofs = ofs * 0.707;
  180.    if (stat == 0)
  181.       {
  182.       self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  183.       org = org + (aofs*v_right);
  184.       org = org - (aofs*v_up);
  185.       HIP_LaunchLaser(org, dir, 0);
  186.       org = org - (2*aofs*v_right);
  187.       HIP_LaunchLaser(org, dir, 0);
  188.       }
  189.    else if (stat == 1)
  190.       {
  191.       self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  192.       org = org + (ofs*v_up);
  193.       if (random()<0.1)
  194.          {
  195.          HIP_LaunchLaser(org, dir, 1);
  196.          newmis.dmg = 25;
  197.          }
  198.       else
  199.          HIP_LaunchLaser(org, dir, 0);
  200.       }
  201.     msg_entity = self;
  202.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  203.    };
  204.  
  205. /*
  206. =================
  207. HIP_HammerDamage
  208. =================
  209. */
  210. void(vector p1, vector p2, entity from, float damage) HIP_HammerDamage =
  211. {
  212.     local entity        e1, e2;
  213.     local vector        f;
  214.  
  215.     f = p2 - p1;
  216.     normalize (f);
  217.     f_x = 0 - f_y;
  218.     f_y = f_x;
  219.     f_z = 0;
  220.     f = f*16;
  221.  
  222.     e1 = e2 = world;
  223.  
  224.     traceline (p1, p2, FALSE, self);
  225. //JIM
  226.     if (trace_ent.takedamage && !trace_ent.wetsuit_finished )
  227.     {
  228.         particle (trace_endpos, '0 0 100', 225, damage*4);
  229.         T_Damage (trace_ent, from, from, damage);
  230.         if (self.classname == "player")
  231.         {
  232.             if (other.classname == "player")
  233.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  234.         }
  235.     }
  236.     e1 = trace_ent;
  237.  
  238.     traceline (p1 + f, p2 + f, FALSE, self);
  239. //JIM
  240.     if (trace_ent != e1 && trace_ent.takedamage &&
  241.         !trace_ent.wetsuit_finished )
  242.     {
  243.         particle (trace_endpos, '0 0 100', 225, damage*4);
  244.         T_Damage (trace_ent, from, from, damage);
  245.     }
  246.     e2 = trace_ent;
  247.  
  248.     traceline (p1 - f, p2 - f, FALSE, self);
  249. //JIM
  250.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage &&
  251.         !trace_ent.wetsuit_finished )
  252.     {
  253.         particle (trace_endpos, '0 0 100', 225, damage*4);
  254.         T_Damage (trace_ent, from, from, damage);
  255.     }
  256. };
  257.  
  258. /*
  259. void() HIP_DiversionLightningThink =
  260.    {
  261.    local vector   org,end;
  262.  
  263.    if (time > self.delay)
  264.       {
  265.       remove(self);
  266.       return;
  267.       }
  268.  
  269.    makevectors(self.v_angle);
  270.    org = self.origin;
  271.    end = org + v_forward*200;
  272. //   end = end + (((200*random()) - 100) * v_up);
  273.    end = end + (((400*random()) - 200) * v_right);
  274.  
  275.    traceline (org, end, TRUE, self);
  276.  
  277.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  278.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  279.     WriteEntity (MSG_BROADCAST, self);
  280.     WriteCoord (MSG_BROADCAST, org_x);
  281.     WriteCoord (MSG_BROADCAST, org_y);
  282.     WriteCoord (MSG_BROADCAST, org_z);
  283.    WriteCoord (MSG_BROADCAST, trace_endpos_x);
  284.    WriteCoord (MSG_BROADCAST, trace_endpos_y);
  285.    WriteCoord (MSG_BROADCAST, trace_endpos_z);
  286.  
  287.    self.nextthink = time + 0.1;
  288.    };
  289. */
  290.  
  291. //void(entity prev, entity owner, float dst) HIP_SpawnMjolnirLightning;
  292. void() HIP_LightningThink =
  293.    {
  294.    local vector org;
  295.    local vector dst;
  296.    local entity head;
  297.    local entity selected;
  298.    local float cur_dist;
  299.    local float head_dist;
  300.    local vector vec;
  301.    local float dot;
  302.    local float oldstate;
  303.    local float dam;
  304.  
  305.  
  306.    if (time > self.delay)
  307.       {
  308.       if (self.enemy != world)
  309.          self.enemy.struck_by_mjolnir = 0;
  310.       remove(self);
  311.       return;
  312.       }
  313.    oldstate = self.state;
  314.    if (self.state==0)
  315.       {
  316.       // look in our immediate vicinity
  317.       self.enemy = world;
  318.       selected = world;
  319.       cur_dist = self.distance;
  320.       head = findradius(self.owner.origin, self.distance);
  321.       while(head)
  322.          {
  323.          if(!(head.flags & FL_NOTARGET) && ((head.flags & FL_MONSTER) || (head.flags & FL_CLIENT)))
  324.             {
  325. //            if (visible(head) && (head!=self.owner.owner) && (head.health>0))
  326.             if ((visible(head)) && (head!=self.owner.owner) && (head.health>0))
  327.                {
  328.                head_dist = vlen(head.origin - self.lastvictim.origin);
  329.                if ((head_dist<cur_dist) && (head.struck_by_mjolnir==0))
  330.                   {
  331.                   selected = head;
  332.                   cur_dist = head_dist;
  333.                   }
  334.                }
  335.             }
  336.          head = head.chain;
  337.          }
  338.       if (selected != world)
  339.          {
  340.          self.state = 1;
  341.          self.enemy = selected;
  342.          self.enemy.struck_by_mjolnir = 1;
  343.          }
  344.       else
  345.          {
  346.          local vector   org,end;
  347.  
  348.          makevectors(self.v_angle);
  349.          org = self.owner.origin;
  350.          end = org + v_forward*200;
  351.          end = end + (((400*random()) - 200) * v_right);
  352.  
  353.          traceline (org, end, TRUE, self);
  354.  
  355.          WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  356.          WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  357.          WriteEntity (MSG_BROADCAST, self);
  358.          WriteCoord (MSG_BROADCAST, org_x);
  359.          WriteCoord (MSG_BROADCAST, org_y);
  360.          WriteCoord (MSG_BROADCAST, org_z);
  361.          WriteCoord (MSG_BROADCAST, trace_endpos_x);
  362.          WriteCoord (MSG_BROADCAST, trace_endpos_y);
  363.          WriteCoord (MSG_BROADCAST, trace_endpos_z);
  364.  
  365.          self.nextthink = time + 0.1;
  366. //         self.think = HIP_DiversionLightningThink;
  367. //         self.nextthink = time;
  368. //         self.delay = time + 0.30;
  369. //         self.origin = self.owner.origin;
  370. //         self.think();
  371.          return;
  372.          }
  373.       }
  374.    org = self.lastvictim.origin;
  375.    dst = self.enemy.absmin + 0.25*(self.enemy.absmax-self.enemy.absmin);
  376.    dst = dst + (random()*0.5*(self.enemy.absmax-self.enemy.absmin));
  377.    traceline (org, dst, TRUE, self.owner.owner);
  378.  
  379.    if (trace_fraction != 1.0 || self.enemy.health<=0)
  380.       {
  381.       self.enemy.struck_by_mjolnir = 0;
  382.       self.state = 0;
  383.       self.nextthink = time + 0.1;
  384.       return;
  385.       }
  386.    WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  387.    WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  388.    WriteEntity (MSG_BROADCAST, self);
  389.    WriteCoord (MSG_BROADCAST, org_x);
  390.    WriteCoord (MSG_BROADCAST, org_y);
  391.    WriteCoord (MSG_BROADCAST, org_z);
  392.    WriteCoord (MSG_BROADCAST, trace_endpos_x);
  393.    WriteCoord (MSG_BROADCAST, trace_endpos_y);
  394.    WriteCoord (MSG_BROADCAST, trace_endpos_z);
  395.    vec = normalize(self.enemy.origin - self.owner.origin);
  396.    dot = vec * self.owner.movedir;
  397.    head = self;
  398.    self = self.owner.owner;
  399.    if (oldstate==0)
  400.       dam = 80;
  401.    else
  402.       dam = 30;
  403.    if (dot>0.3)
  404.       HIP_HammerDamage (org, trace_endpos, self, dam);
  405.    else
  406.       HIP_HammerDamage (org, trace_endpos, self, dam*0.5);
  407.    self = head;
  408.  
  409.    self.nextthink = time + 0.2;
  410.    };
  411.  
  412. void(entity prev, entity own, float dst) HIP_SpawnMjolnirLightning =
  413.    {
  414.    local entity light;
  415.    // spawn actual lightning
  416.    light = spawn();
  417.    light.delay = time + 0.8;
  418.    light.state = 0;
  419.    light.lastvictim = prev;
  420.    light.distance = dst;
  421.    light.owner = own;
  422.    light.v_angle = self.angles;
  423.    light.v_angle_x = 0;
  424.    light.v_angle_z = 0;
  425.    light.origin = own.origin;
  426.    light.think = HIP_LightningThink;
  427.    light.nextthink = time;
  428.    };
  429.  
  430. void() HIP_SpawnMjolnirBase =
  431.    {
  432.    local entity light;
  433.    // spawn lightning base
  434.    light = spawn();
  435. //   light.origin = self.origin - '0 0 24' + (32*v_forward);
  436.    light.origin = trace_endpos;
  437.    light.flags = 0;
  438.    light.owner = self;
  439.    light.struck_by_mjolnir = 1;
  440.    light.think = SUB_Remove;
  441.    light.nextthink = time + 1;
  442.    sound (light, CHAN_AUTO, "hipweap/mjolslap.wav", 1, ATTN_NORM);
  443.    sound (light, CHAN_WEAPON, "hipweap/mjolhit.wav", 1, ATTN_NORM);
  444.    makevectors(self.v_angle);
  445.    light.movedir = v_forward;
  446.    HIP_SpawnMjolnirLightning( light, light, 350 );
  447.    HIP_SpawnMjolnirLightning( light, light, 350 );
  448.    HIP_SpawnMjolnirLightning( light, light, 350 );
  449.    HIP_SpawnMjolnirLightning( light, light, 350 );
  450.    };
  451.  
  452. void() HIP_FireMjolnirLightning =
  453.    {
  454.    local vector   org;
  455.     local    float        cells;
  456.  
  457. // explode if under water
  458.     if (self.waterlevel > 1)
  459.     {
  460.         cells = self.ammo_cells;
  461.         self.ammo_cells = 0;
  462.       discharged = 1;
  463.         T_RadiusDamage (self, self, 35*cells, world);
  464.       discharged = 0;
  465.         W_SetCurrentAmmo ();
  466.         return;
  467.     }
  468.  
  469. //   if (self.t_width < time)
  470. //   {
  471. //      sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  472. //      self.t_width = time + 0.6;
  473. //   }
  474. //   self.punchangle_x = 12;
  475.  
  476.    self.currentammo = self.ammo_cells = self.ammo_cells - 15;
  477.  
  478.    HIP_SpawnMjolnirBase();
  479.    };
  480.  
  481. void() HIP_FireMjolnir =
  482.    {
  483.    local vector   org;
  484.     local    float        cells;
  485.    local float    damage;
  486.    local vector   source;
  487.    local vector   ang;
  488.  
  489.  
  490.    self.attack_finished = time + 0.4;
  491.    source = self.origin + '0 0 16';
  492. //   ang = self.angles;
  493. //   ang_x = 0;
  494. //   ang_y = 0;
  495.    makevectors(self.v_angle);
  496.    traceline (source, source + v_forward*32, FALSE, self);
  497.    if (trace_fraction == 1.0 && (self.ammo_cells >= 15))
  498.       {
  499.       source = source + v_forward*32;
  500.       traceline (source , source - v_up*50, FALSE, self);
  501. //      dprint("fraction = ");
  502. //      dprint(ftos(trace_fraction));
  503. //      dprint("\n");
  504.       if (trace_fraction > 0.3 && trace_fraction< 1.0)
  505.          {
  506.          HIP_FireMjolnirLightning();
  507.          self.attack_finished = time + 1.5;
  508.          return;
  509.          }
  510.       }
  511.    org = trace_endpos - v_forward*4;
  512.  
  513.    if (trace_ent.takedamage)
  514.       {
  515.       damage = 50;
  516.       if (trace_ent.classname == "monster_zombie")
  517.          damage = 70;
  518.       trace_ent.axhitme = 1;
  519.       SpawnBlood (org, damage);
  520.       T_Damage (trace_ent, self, self, damage);
  521.       }
  522.    else
  523.       {  // hit wall
  524.       if (trace_fraction != 1.0)
  525.          {
  526. //         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  527.          sound (self, CHAN_WEAPON, "hipweap/mjoltink.wav", 1, ATTN_NORM);
  528.          WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  529.          WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  530.          WriteCoord (MSG_BROADCAST, org_x);
  531.          WriteCoord (MSG_BROADCAST, org_y);
  532.          WriteCoord (MSG_BROADCAST, org_z);
  533.          }
  534.       else
  535.          {
  536.          sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM);
  537.          }
  538.       }
  539.    self.attack_finished = time + 0.4;
  540.  
  541.    };
  542. //hip
  543.  
  544.  
  545. // called by worldspawn
  546. void() W_Precache =
  547. {
  548.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  549.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  550.     precache_sound ("weapons/sgun1.wav");
  551.     precache_sound ("weapons/guncock.wav");    // player shotgun
  552.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  553.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  554.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  555.     precache_sound ("weapons/spike2.wav");    // super spikes
  556.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  557.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  558.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  559.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  560. //hip
  561. //MED
  562.    precache_sound ("enforcer/enfstop.wav");   // laser cannon
  563. //MED 11/06/96
  564.    precache_sound ("knight/sword1.wav");   // laser cannon
  565.    precache_sound ("hipweap/laserg.wav");   // laser cannon
  566.    precache_sound ("hipweap/laserric.wav");   // laser cannon ricochet
  567.    precache_sound ("hipweap/proxwarn.wav");   // proximity bomb
  568.    precache_sound ("hipweap/proxbomb.wav");   // proximity bomb
  569. //MED 11/19/96
  570.    precache_sound ("hipweap/mjolhit.wav");   // mjolnir
  571.    precache_sound ("hipweap/mjolslap.wav");   // mjolnir
  572.    precache_sound ("hipweap/mjoltink.wav");   // mjolnir
  573. //hip
  574. };
  575.  
  576. float() crandom =
  577. {
  578.     return 2*(random() - 0.5);
  579. };
  580.  
  581. /*
  582. ================
  583. W_FireAxe
  584. ================
  585. */
  586. void() W_FireAxe =
  587. {
  588.     local    vector    source;
  589.     local    vector    org;
  590.  
  591.     makevectors (self.v_angle);
  592.     source = self.origin + '0 0 16';
  593.     traceline (source, source + v_forward*64, FALSE, self);
  594.     if (trace_fraction == 1.0)
  595.         return;
  596.     
  597.     org = trace_endpos - v_forward*4;
  598.  
  599.     if (trace_ent.takedamage)
  600.     {
  601.         trace_ent.axhitme = 1;
  602.         SpawnBlood (org, 20);
  603.         T_Damage (trace_ent, self, self, 20);
  604.     }
  605.     else
  606.     {    // hit wall
  607.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  608.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  609.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  610.         WriteCoord (MSG_BROADCAST, org_x);
  611.         WriteCoord (MSG_BROADCAST, org_y);
  612.         WriteCoord (MSG_BROADCAST, org_z);
  613.     }
  614. };
  615.  
  616.  
  617. //============================================================================
  618.  
  619.  
  620. vector() wall_velocity =
  621. {
  622.     local vector    vel;
  623.     
  624.     vel = normalize (self.velocity);
  625.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  626.     vel = vel + 2*trace_plane_normal;
  627.     vel = vel * 200;
  628.     
  629.     return vel;
  630. };
  631.  
  632.  
  633. /*
  634. ================
  635. SpawnMeatSpray
  636. ================
  637. */
  638. void(vector org, vector vel) SpawnMeatSpray =
  639. {
  640.     local    entity missile;
  641.     local    vector    org;
  642.  
  643.     missile = spawn ();
  644.     missile.owner = self;
  645.     missile.movetype = MOVETYPE_BOUNCE;
  646.     missile.solid = SOLID_NOT;
  647.  
  648.     makevectors (self.angles);
  649.  
  650.     missile.velocity = vel;
  651.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  652.  
  653.     missile.avelocity = '3000 1000 2000';
  654.     
  655. // set missile duration
  656.     missile.nextthink = time + 1;
  657.     missile.think = SUB_Remove;
  658.  
  659.     setmodel (missile, "progs/zom_gib.mdl");
  660.     setsize (missile, '0 0 0', '0 0 0');        
  661.     setorigin (missile, org);
  662. };
  663.  
  664. /*
  665. ================
  666. SpawnBlood
  667. ================
  668. */
  669. void(vector org, float damage) SpawnBlood =
  670. {
  671.     particle (org, VEC_ORIGIN, 73, damage*2);
  672. };
  673.  
  674. /*
  675. ================
  676. spawn_touchblood
  677. ================
  678. */
  679. void(float damage) spawn_touchblood =
  680. {
  681.     local vector    vel;
  682.  
  683.     vel = wall_velocity () * 0.2;
  684.     SpawnBlood (self.origin + vel*0.01, damage);
  685. };
  686.  
  687.  
  688. /*
  689. ==============================================================================
  690.  
  691. MULTI-DAMAGE
  692.  
  693. Collects multiple small damages into a single damage
  694.  
  695. ==============================================================================
  696. */
  697.  
  698. entity    multi_ent;
  699. float    multi_damage;
  700.  
  701. void() ClearMultiDamage =
  702. {
  703.     multi_ent = world;
  704.     multi_damage = 0;
  705. };
  706.  
  707. void() ApplyMultiDamage =
  708. {
  709.     if (!multi_ent)
  710.         return;
  711.     T_Damage (multi_ent, self, self, multi_damage);
  712. };
  713.  
  714. void(entity hit, float damage) AddMultiDamage =
  715. {
  716.     if (!hit)
  717.         return;
  718.     
  719.     if (hit != multi_ent)
  720.     {
  721.         ApplyMultiDamage ();
  722.         multi_damage = damage;
  723.         multi_ent = hit;
  724.     }
  725.     else
  726.         multi_damage = multi_damage + damage;
  727. };
  728.  
  729. /*
  730. ==============================================================================
  731.  
  732. BULLETS
  733.  
  734. ==============================================================================
  735. */
  736.  
  737. /*
  738. ================
  739. TraceAttack
  740. ================
  741. */
  742. void(float damage, vector dir) TraceAttack =
  743. {
  744.     local    vector    vel, org;
  745.     
  746.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  747.     vel = vel + 2*trace_plane_normal;
  748.     vel = vel * 200;
  749.  
  750.     org = trace_endpos - dir*4;
  751.  
  752.     if (trace_ent.takedamage)
  753.     {
  754.         SpawnBlood (org, damage);
  755.         AddMultiDamage (trace_ent, damage);
  756.     }
  757.     else
  758.     {
  759.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  760.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  761.         WriteCoord (MSG_BROADCAST, org_x);
  762.         WriteCoord (MSG_BROADCAST, org_y);
  763.         WriteCoord (MSG_BROADCAST, org_z);
  764.     }
  765. };
  766.  
  767. /*
  768. ================
  769. FireBullets
  770.  
  771. Used by shotgun, super shotgun, and enemy soldier firing
  772. Go to the trouble of combining multiple pellets into a single damage call.
  773. ================
  774. */
  775. void(float shotcount, vector dir, vector spread) FireBullets =
  776. {
  777.     local    vector direction;
  778.     local    vector    src;
  779.  
  780. //hip
  781.    //JIM
  782.    local float bullet;
  783.    bullet = 0;
  784. //hip
  785.  
  786.     makevectors(self.v_angle);
  787.  
  788.     src = self.origin + v_forward*10;
  789.     src_z = self.absmin_z + self.size_z * 0.7;
  790.  
  791.     ClearMultiDamage ();
  792.     while (shotcount > 0)
  793.     {
  794.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  795.  
  796.         traceline (src, src + direction*2048, FALSE, self);
  797.         if (trace_fraction != 1.0)
  798. //hip
  799.  //JIM
  800.          {
  801. //hip
  802.             TraceAttack (4, direction);
  803. //hip
  804.          if ( ( !bullet ) && ( trace_ent == world ) )
  805.             {
  806.             placebullethole( trace_endpos );
  807.             bullet = 1;
  808.             }
  809.          }
  810. //hip
  811.         shotcount = shotcount - 1;
  812.     }
  813.     ApplyMultiDamage ();
  814. };
  815.  
  816. /*
  817. ================
  818. W_FireShotgun
  819. ================
  820. */
  821. void() W_FireShotgun =
  822. {
  823.     local vector dir;
  824.  
  825.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  826.  
  827.     msg_entity = self;
  828.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  829.     
  830.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  831.     dir = aim (self, 100000);
  832.     FireBullets (6, dir, '0.04 0.04 0');
  833. };
  834.  
  835.  
  836. /*
  837. ================
  838. W_FireSuperShotgun
  839. ================
  840. */
  841. void() W_FireSuperShotgun =
  842. {
  843.     local vector dir;
  844.  
  845.     if (self.currentammo == 1)
  846.     {
  847.         W_FireShotgun ();
  848.         return;
  849.     }
  850.         
  851.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  852.  
  853.     msg_entity = self;
  854.     WriteByte (MSG_ONE, SVC_BIGKICK);
  855.     
  856.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  857.     dir = aim (self, 100000);
  858.     FireBullets (14, dir, '0.14 0.08 0');
  859. };
  860.  
  861.  
  862. /*
  863. ==============================================================================
  864.  
  865. ROCKETS
  866.  
  867. ==============================================================================
  868. */
  869.  
  870. void() T_MissileTouch =
  871. {
  872.     local float    damg;
  873.  
  874.     if (other == self.owner)
  875.         return;        // don't explode on owner
  876.  
  877.     if (pointcontents(self.origin) == CONTENT_SKY)
  878.     {
  879.         remove(self);
  880.         return;
  881.     }
  882.  
  883.     damg = 100 + random()*20;
  884.     
  885.     if (other.health)
  886.     {
  887.         if (other.classname == "monster_shambler")
  888.             damg = damg * 0.5;    // mostly immune
  889.         T_Damage (other, self, self.owner, damg );
  890.     }
  891.  
  892.     // don't do radius damage to the other, because all the damage
  893.     // was done in the impact
  894.     T_RadiusDamage (self, self.owner, 120, other);
  895.  
  896. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  897.     self.origin = self.origin - 8*normalize(self.velocity);
  898.  
  899.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  900.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  901.     WriteCoord (MSG_BROADCAST, self.origin_x);
  902.     WriteCoord (MSG_BROADCAST, self.origin_y);
  903.     WriteCoord (MSG_BROADCAST, self.origin_z);
  904.     remove(self);
  905. };
  906.  
  907.  
  908.  
  909. /*
  910. ================
  911. W_FireRocket
  912. ================
  913. */
  914. void() W_FireRocket =
  915. {
  916.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  917.     
  918.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  919.  
  920.     msg_entity = self;
  921.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  922.  
  923.     newmis = spawn ();
  924.     newmis.owner = self;
  925.     newmis.movetype = MOVETYPE_FLYMISSILE;
  926.     newmis.solid = SOLID_BBOX;
  927.         
  928. // set newmis speed    
  929.  
  930.     makevectors (self.v_angle);
  931.     newmis.velocity = aim(self, 1000);
  932.     newmis.velocity = newmis.velocity * 1000;
  933.     newmis.angles = vectoangles(newmis.velocity);
  934.     
  935.     newmis.touch = T_MissileTouch;
  936.     
  937. // set newmis duration
  938.     newmis.nextthink = time + 5;
  939.     newmis.think = SUB_Remove;
  940.  
  941.     setmodel (newmis, "progs/missile.mdl");
  942.     setsize (newmis, '0 0 0', '0 0 0');        
  943.     setorigin (newmis, self.origin + v_forward*8 + '0 0 16');
  944. //hip
  945. //MED 11/09/96
  946. //   newmis = missile;
  947. //hip
  948. };
  949.  
  950. /*
  951. ===============================================================================
  952.  
  953. LIGHTNING
  954.  
  955. ===============================================================================
  956. */
  957.  
  958. /*
  959. =================
  960. LightningDamage
  961. =================
  962. */
  963. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  964. {
  965.     local entity        e1, e2;
  966.     local vector        f;
  967.     
  968.     f = p2 - p1;
  969.     normalize (f);
  970.     f_x = 0 - f_y;
  971.     f_y = f_x;
  972.     f_z = 0;
  973.     f = f*16;
  974.  
  975.     e1 = e2 = world;
  976.  
  977.     traceline (p1, p2, FALSE, self);
  978. //hip
  979.     //if (trace_ent.takedamage)
  980. //JIM
  981.     if (trace_ent.takedamage && !trace_ent.wetsuit_finished )
  982. //hip
  983.     {
  984.         particle (trace_endpos, '0 0 100', 225, damage*4);
  985.         T_Damage (trace_ent, from, from, damage);
  986.         if (self.classname == "player")
  987.         {
  988.             if (other.classname == "player")
  989.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  990.         }
  991.     }
  992.     e1 = trace_ent;
  993.  
  994.     traceline (p1 + f, p2 + f, FALSE, self);
  995. //hip
  996. //    if (trace_ent != e1 && trace_ent.takedamage)
  997. //JIM
  998.     if (trace_ent != e1 && trace_ent.takedamage &&
  999.         !trace_ent.wetsuit_finished )
  1000. //hip
  1001.     {
  1002.         particle (trace_endpos, '0 0 100', 225, damage*4);
  1003.         T_Damage (trace_ent, from, from, damage);
  1004.     }
  1005.     e2 = trace_ent;
  1006.  
  1007.     traceline (p1 - f, p2 - f, FALSE, self);
  1008. //hip
  1009. //    if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  1010. //JIM
  1011.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage &&
  1012.         !trace_ent.wetsuit_finished )
  1013. //hip
  1014.     {
  1015.         particle (trace_endpos, '0 0 100', 225, damage*4);
  1016.         T_Damage (trace_ent, from, from, damage);
  1017.     }
  1018. };
  1019.  
  1020.  
  1021. void() W_FireLightning =
  1022. {
  1023.     local    vector        org;
  1024.     local    float        cells;
  1025.  
  1026.     if (self.ammo_cells < 1)
  1027.     {
  1028.         self.weapon = W_BestWeapon ();
  1029.         W_SetCurrentAmmo ();
  1030.         return;
  1031.     }
  1032.  
  1033. // explode if under water
  1034.     if (self.waterlevel > 1)
  1035.     {
  1036.         cells = self.ammo_cells;
  1037.         self.ammo_cells = 0;
  1038. //hip
  1039.       //MED 01/05/97 added discharge flag
  1040.       discharged = 1;
  1041. //hip
  1042.         T_RadiusDamage (self, self, 35*cells, world);
  1043. //hip
  1044.       discharged = 0;
  1045. //hip
  1046.         W_SetCurrentAmmo ();
  1047.         return;
  1048.     }
  1049.  
  1050.     if (self.t_width < time)
  1051.     {
  1052.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  1053.         self.t_width = time + 0.6;
  1054.     }
  1055.     msg_entity = self;
  1056.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  1057.  
  1058.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  1059.  
  1060.     org = self.origin + '0 0 16';
  1061.     
  1062.     traceline (org, org + v_forward*600, TRUE, self);
  1063.  
  1064.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1065.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  1066.     WriteEntity (MSG_BROADCAST, self);
  1067.     WriteCoord (MSG_BROADCAST, org_x);
  1068.     WriteCoord (MSG_BROADCAST, org_y);
  1069.     WriteCoord (MSG_BROADCAST, org_z);
  1070.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  1071.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  1072.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  1073.  
  1074.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  1075. };
  1076.  
  1077.  
  1078. //=============================================================================
  1079.  
  1080.  
  1081. void() GrenadeExplode =
  1082. {
  1083.     T_RadiusDamage (self, self.owner, 120, world);
  1084.  
  1085.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1086.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  1087.     WriteCoord (MSG_BROADCAST, self.origin_x);
  1088.     WriteCoord (MSG_BROADCAST, self.origin_y);
  1089.     WriteCoord (MSG_BROADCAST, self.origin_z);
  1090.     remove (self);
  1091. };
  1092.  
  1093. void() GrenadeTouch =
  1094. {
  1095.     if (other == self.owner)
  1096.         return;        // don't explode on owner
  1097.     if (other.takedamage == DAMAGE_AIM)
  1098.     {
  1099.         GrenadeExplode();
  1100.         return;
  1101.     }
  1102.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  1103.     if (self.velocity == '0 0 0')
  1104.         self.avelocity = '0 0 0';
  1105. };
  1106.  
  1107. /*
  1108. ================
  1109. W_FireGrenade
  1110. ================
  1111. */
  1112. void() W_FireGrenade =
  1113. {    
  1114.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  1115.     
  1116.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  1117.  
  1118.     msg_entity = self;
  1119.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  1120.  
  1121.     newmis = spawn ();
  1122.     newmis.owner = self;
  1123.     newmis.movetype = MOVETYPE_BOUNCE;
  1124.     newmis.solid = SOLID_BBOX;
  1125.     newmis.classname = "grenade";
  1126.         
  1127. // set newmis speed    
  1128.  
  1129.     makevectors (self.v_angle);
  1130.  
  1131.     if (self.v_angle_x)
  1132.         newmis.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  1133.     else
  1134.     {
  1135.         newmis.velocity = aim(self, 10000);
  1136.         newmis.velocity = newmis.velocity * 600;
  1137.         newmis.velocity_z = 200;
  1138.     }
  1139.  
  1140.     newmis.avelocity = '300 300 300';
  1141.  
  1142.     newmis.angles = vectoangles(newmis.velocity);
  1143.     
  1144.     newmis.touch = GrenadeTouch;
  1145.     
  1146. // set newmis duration
  1147.     newmis.nextthink = time + 2.5;
  1148.     newmis.think = GrenadeExplode;
  1149.  
  1150.     setmodel (newmis, "progs/grenade.mdl");
  1151.     setsize (newmis, '0 0 0', '0 0 0');        
  1152.     setorigin (newmis, self.origin);
  1153. };
  1154.  
  1155.  
  1156. void() ProximityExplode =
  1157. {
  1158.    T_RadiusDamage (self, self.owner, 95, world);
  1159.  
  1160.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1161.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  1162.     WriteCoord (MSG_BROADCAST, self.origin_x);
  1163.     WriteCoord (MSG_BROADCAST, self.origin_y);
  1164.     WriteCoord (MSG_BROADCAST, self.origin_z);
  1165.     remove (self);
  1166. };
  1167.  
  1168. //MED 10/31/96
  1169. float NumProximityGrenades;
  1170. /*
  1171. ================
  1172. ProximityGrenadeExplode
  1173. ================
  1174. */
  1175. void() ProximityGrenadeExplode =
  1176.    {
  1177.    self.takedamage = DAMAGE_NO;
  1178.    NumProximityGrenades = NumProximityGrenades - 1;
  1179.    self.deathtype = "exploding";
  1180.    self.nextthink = time + 0.1;
  1181.    self.owner = self.lastvictim;
  1182.    self.think = ProximityExplode;
  1183.    };
  1184.  
  1185. /*
  1186. ================
  1187. ProximityGrenadeTouch
  1188. ================
  1189. */
  1190. void() ProximityGrenadeTouch =
  1191.    {
  1192.    if (other == self)
  1193.       return;
  1194.    if (other.classname == self.classname)
  1195.       return;
  1196.    self.movetype = MOVETYPE_TOSS;
  1197.    if (self.state == 1)
  1198.       return;
  1199.    if (vlen(other.velocity) > 0)
  1200.       {
  1201.       ProximityGrenadeExplode();
  1202.       self.think();
  1203.       return;
  1204.       }
  1205.    if (other.takedamage == DAMAGE_AIM)
  1206.       {
  1207.       ProximityGrenadeExplode();
  1208.       self.think();
  1209.       return;
  1210.       }
  1211.    sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
  1212.    self.movetype = MOVETYPE_NONE;
  1213.    setsize (self, '-8 -8 -8', '8 8 8');
  1214.    self.state = 1;
  1215.    self.spawnmaster = other;
  1216.    };
  1217.  
  1218. /*
  1219. ================
  1220. ProximityBomb
  1221. ================
  1222. */
  1223. void() ProximityBomb =
  1224.    {
  1225.    local entity   head;
  1226.    local float    blowup;
  1227.  
  1228.    if ((time > self.delay) || (NumProximityGrenades > 15) || (vlen(self.spawnmaster.velocity)>0) )
  1229.       {
  1230.       ProximityGrenadeExplode();
  1231.       self.think();
  1232.       return;
  1233.       }
  1234.    self.owner = world;
  1235.    self.takedamage = DAMAGE_YES;
  1236.    head = findradius(self.origin, 140);
  1237.    blowup = 0;
  1238.  
  1239.    while (head)
  1240.       {
  1241.       if ((head != self) && (head.health > 0) && (head.flags & (FL_CLIENT|FL_MONSTER)) && (head.classname!=self.classname))
  1242.          blowup = 1;
  1243.       if ((head.classname == self.classname) && (head.state==0))
  1244.          blowup = 1;
  1245.       traceline(self.origin,head.origin,TRUE,self);
  1246.       if (trace_fraction != 1.0)
  1247.          blowup = 0;
  1248.       if (blowup==1)
  1249.          {
  1250.          sound (self, CHAN_WEAPON, "hipweap/proxwarn.wav", 1, ATTN_NORM);
  1251.          ProximityGrenadeExplode();
  1252.          self.nextthink = time + 0.5;
  1253.          return;
  1254.          }
  1255.       head = head.chain;
  1256.       }
  1257.    self.nextthink = time + 0.25;
  1258.    };
  1259.  
  1260. /*
  1261. ================
  1262. W_FireProximityGrenade
  1263. ================
  1264. */
  1265. void() W_FireProximityGrenade =
  1266.    {
  1267.    local entity missile, mpuff;
  1268.  
  1269.    NumProximityGrenades = NumProximityGrenades + 1;
  1270.    self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  1271.  
  1272.    sound (self, CHAN_WEAPON, "hipweap/proxbomb.wav", 1, ATTN_NORM);
  1273.  
  1274.     msg_entity = self;
  1275.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  1276.  
  1277.     missile = spawn ();
  1278.    missile.owner = self;
  1279.    missile.lastvictim = self;
  1280.    missile.movetype = MOVETYPE_TOSS;
  1281.     missile.solid = SOLID_BBOX;
  1282.    missile.classname = "proximity_grenade";
  1283.    missile.takedamage = DAMAGE_NO;
  1284.    missile.health = 5;
  1285.    missile.state = 0;
  1286.  
  1287. // set missile speed
  1288.  
  1289.     makevectors (self.v_angle);
  1290.  
  1291.     if (self.v_angle_x)
  1292.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  1293.     else
  1294.     {
  1295.         missile.velocity = aim(self, 10000);
  1296.         missile.velocity = missile.velocity * 600;
  1297.         missile.velocity_z = 200;
  1298.     }
  1299.  
  1300.    missile.avelocity = '100 600 100';
  1301.  
  1302.     missile.angles = vectoangles(missile.velocity);
  1303.  
  1304.    missile.touch = ProximityGrenadeTouch;
  1305.  
  1306. // set missile duration
  1307.    missile.nextthink = time + 2;
  1308.    missile.delay = time + 15 + (10*random());
  1309.    missile.think = ProximityBomb;
  1310.    missile.th_die = ProximityGrenadeExplode;
  1311.  
  1312.    setmodel (missile, "progs/proxbomb.mdl");
  1313.    setorigin (missile, self.origin);
  1314.    setsize (missile, '-1 -1 -1', '1 1 1');
  1315. };
  1316.  
  1317.  
  1318. //=============================================================================
  1319.  
  1320. void() spike_touch;
  1321. void() superspike_touch;
  1322.  
  1323.  
  1324. /*
  1325. ===============
  1326. launch_spike
  1327.  
  1328. Used for both the player and the ogre
  1329. ===============
  1330. */
  1331. void(vector org, vector dir) launch_spike =
  1332. {
  1333.     newmis = spawn ();
  1334.     newmis.owner = self;
  1335.     newmis.movetype = MOVETYPE_FLYMISSILE;
  1336.     newmis.solid = SOLID_BBOX;
  1337.  
  1338.     newmis.angles = vectoangles(dir);
  1339.     
  1340.     newmis.touch = spike_touch;
  1341.     newmis.classname = "spike";
  1342.     newmis.think = SUB_Remove;
  1343.     newmis.nextthink = time + 6;
  1344.     setmodel (newmis, "progs/spike.mdl");
  1345.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  1346.     setorigin (newmis, org);
  1347.  
  1348.     newmis.velocity = dir * 1000;
  1349. };
  1350.  
  1351. void() W_FireSuperSpikes =
  1352. {
  1353.     local vector    dir;
  1354.     local entity    old;
  1355.     
  1356.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  1357.     self.attack_finished = time + 0.2;
  1358.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  1359.     dir = aim (self, 1000);
  1360.     launch_spike (self.origin + '0 0 16', dir);
  1361.     newmis.touch = superspike_touch;
  1362.     setmodel (newmis, "progs/s_spike.mdl");
  1363.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  1364.     msg_entity = self;
  1365.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  1366. };
  1367.  
  1368. void(float ox) W_FireSpikes =
  1369. {
  1370.     local vector    dir;
  1371.     local entity    old;
  1372.     
  1373.     makevectors (self.v_angle);
  1374.     
  1375.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  1376.     {
  1377.         W_FireSuperSpikes ();
  1378.         return;
  1379.     }
  1380.  
  1381.     if (self.ammo_nails < 1)
  1382.     {
  1383.         self.weapon = W_BestWeapon ();
  1384.         W_SetCurrentAmmo ();
  1385.         return;
  1386.     }
  1387.  
  1388.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  1389.     self.attack_finished = time + 0.2;
  1390.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  1391.     dir = aim (self, 1000);
  1392.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  1393.  
  1394.     msg_entity = self;
  1395.     WriteByte (MSG_ONE, SVC_SMALLKICK);
  1396. };
  1397.  
  1398.  
  1399.  
  1400. .float hit_z;
  1401. void() spike_touch =
  1402. {
  1403. local float rand;
  1404.     if (other == self.owner)
  1405.         return;
  1406.  
  1407.     if (other.solid == SOLID_TRIGGER)
  1408.         return;    // trigger field, do nothing
  1409.  
  1410.     if (pointcontents(self.origin) == CONTENT_SKY)
  1411.     {
  1412.         remove(self);
  1413.         return;
  1414.     }
  1415.     
  1416. // hit something that bleeds
  1417.     if (other.takedamage)
  1418.     {
  1419.         spawn_touchblood (9);
  1420.         T_Damage (other, self, self.owner, 9);
  1421.     }
  1422.     else
  1423.     {
  1424.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1425.         
  1426.         if (self.classname == "wizspike")
  1427.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  1428.         else if (self.classname == "knightspike")
  1429.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  1430.         else
  1431.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  1432.         WriteCoord (MSG_BROADCAST, self.origin_x);
  1433.         WriteCoord (MSG_BROADCAST, self.origin_y);
  1434.         WriteCoord (MSG_BROADCAST, self.origin_z);
  1435.     }
  1436.  
  1437.     remove(self);
  1438.  
  1439. };
  1440.  
  1441. void() superspike_touch =
  1442. {
  1443. local float rand;
  1444.     if (other == self.owner)
  1445.         return;
  1446.  
  1447.     if (other.solid == SOLID_TRIGGER)
  1448.         return;    // trigger field, do nothing
  1449.  
  1450.     if (pointcontents(self.origin) == CONTENT_SKY)
  1451.     {
  1452.         remove(self);
  1453.         return;
  1454.     }
  1455.     
  1456. // hit something that bleeds
  1457.     if (other.takedamage)
  1458.     {
  1459.         spawn_touchblood (18);
  1460.         T_Damage (other, self, self.owner, 18);
  1461.     }
  1462.     else
  1463.     {
  1464.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1465.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  1466.         WriteCoord (MSG_BROADCAST, self.origin_x);
  1467.         WriteCoord (MSG_BROADCAST, self.origin_y);
  1468.         WriteCoord (MSG_BROADCAST, self.origin_z);
  1469.     }
  1470.  
  1471.     remove(self);
  1472.  
  1473. };
  1474.  
  1475.  
  1476. /*
  1477. ===============================================================================
  1478.  
  1479. PLAYER WEAPON USE
  1480.  
  1481. ===============================================================================
  1482. */
  1483.  
  1484. //hip
  1485. //MED 10/18/96 added HIPWEAPONS
  1486. //hip
  1487. void() W_SetCurrentAmmo =
  1488. {
  1489.     player_run ();        // get out of any weapon firing states
  1490.  
  1491.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  1492.     
  1493.     if (self.weapon == IT_AXE)
  1494.     {
  1495.         self.currentammo = 0;
  1496.         self.weaponmodel = "progs/v_axe.mdl";
  1497.         self.weaponframe = 0;
  1498.     }
  1499.     else if (self.weapon == IT_SHOTGUN)
  1500.     {
  1501.         self.currentammo = self.ammo_shells;
  1502.         self.weaponmodel = "progs/v_shot.mdl";
  1503.         self.weaponframe = 0;
  1504.         self.items = self.items | IT_SHELLS;
  1505.     }
  1506.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1507.     {
  1508.         self.currentammo = self.ammo_shells;
  1509.         self.weaponmodel = "progs/v_shot2.mdl";
  1510.         self.weaponframe = 0;
  1511.         self.items = self.items | IT_SHELLS;
  1512.     }
  1513.     else if (self.weapon == IT_NAILGUN)
  1514.     {
  1515.         self.currentammo = self.ammo_nails;
  1516.         self.weaponmodel = "progs/v_nail.mdl";
  1517.         self.weaponframe = 0;
  1518.         self.items = self.items | IT_NAILS;
  1519.     }
  1520.     else if (self.weapon == IT_SUPER_NAILGUN)
  1521.     {
  1522.         self.currentammo = self.ammo_nails;
  1523.         self.weaponmodel = "progs/v_nail2.mdl";
  1524.         self.weaponframe = 0;
  1525.         self.items = self.items | IT_NAILS;
  1526.     }
  1527. //hip
  1528. //MED
  1529.    else if (self.weapon == IT_LASER_CANNON)
  1530.     {
  1531.         self.currentammo = self.ammo_cells;
  1532.       self.weaponmodel = "progs/v_laserg.mdl";
  1533.         self.weaponframe = 0;
  1534.         self.items = self.items | IT_CELLS;
  1535.     }
  1536. //hip
  1537.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1538.     {
  1539.         self.currentammo = self.ammo_rockets;
  1540.         self.weaponmodel = "progs/v_rock.mdl";
  1541.         self.weaponframe = 0;
  1542.         self.items = self.items | IT_ROCKETS;
  1543.     }
  1544.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1545.     {
  1546.         self.currentammo = self.ammo_rockets;
  1547.         self.weaponmodel = "progs/v_rock2.mdl";
  1548.         self.weaponframe = 0;
  1549.         self.items = self.items | IT_ROCKETS;
  1550.     }
  1551.     else if (self.weapon == IT_LIGHTNING)
  1552.     {
  1553.         self.currentammo = self.ammo_cells;
  1554.         self.weaponmodel = "progs/v_light.mdl";
  1555.         self.weaponframe = 0;
  1556.         self.items = self.items | IT_CELLS;
  1557.     }
  1558. //hip
  1559. //MED
  1560.    else if (self.weapon == IT_MJOLNIR)
  1561.     {
  1562.       self.currentammo = self.ammo_cells;
  1563.       self.weaponmodel = "progs/v_hammer.mdl";
  1564.         self.weaponframe = 0;
  1565.         self.items = self.items | IT_CELLS;
  1566.     }
  1567. //MED
  1568.    else if (self.weapon == IT_PROXIMITY_GUN)
  1569.     {
  1570.       self.currentammo = self.ammo_rockets;
  1571.       self.weaponmodel = "progs/v_prox.mdl";
  1572.         self.weaponframe = 0;
  1573.       self.items = self.items | IT_ROCKETS;
  1574.     }
  1575. //hip
  1576.     else
  1577.     {
  1578.         self.currentammo = 0;
  1579.         self.weaponmodel = "";
  1580.         self.weaponframe = 0;
  1581.     }
  1582. };
  1583.  
  1584. float() W_BestWeapon =
  1585. {
  1586.     local    float    it;
  1587.     
  1588.     it = self.items;
  1589.  
  1590.     if (self.waterlevel <= 1 && self.ammo_cells >= 15 && (it & IT_MJOLNIR) )
  1591.         return IT_MJOLNIR;
  1592.  
  1593.     if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  1594.         return IT_LIGHTNING;
  1595. //hip
  1596. //MED
  1597.    else if(self.ammo_cells >= 1 && (it & IT_LASER_CANNON) )
  1598.         return IT_LASER_CANNON;
  1599. //hip
  1600.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  1601.         return IT_SUPER_NAILGUN;
  1602.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  1603.         return IT_SUPER_SHOTGUN;
  1604.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  1605.         return IT_NAILGUN;
  1606.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  1607.         return IT_SHOTGUN;
  1608.     //MED
  1609.    else if( it & IT_MJOLNIR )
  1610.       return IT_MJOLNIR;
  1611. /*
  1612.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  1613.         return IT_ROCKET_LAUNCHER;
  1614.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  1615.         return IT_GRENADE_LAUNCHER;
  1616.  
  1617. */
  1618.  
  1619.     return IT_AXE;
  1620. };
  1621.  
  1622. float() W_CheckNoAmmo =
  1623. {
  1624.     if (self.currentammo > 0)
  1625.         return TRUE;
  1626.  
  1627.     if (self.weapon == IT_AXE)
  1628.         return TRUE;
  1629. //hip
  1630. //MED
  1631.    if (self.weapon == IT_MJOLNIR)
  1632.       {
  1633.       return TRUE;
  1634.       }
  1635. //hip
  1636.     
  1637.     self.weapon = W_BestWeapon ();
  1638.  
  1639.     W_SetCurrentAmmo ();
  1640.     
  1641. // drop the weapon down
  1642.     return FALSE;
  1643. };
  1644.  
  1645. /*
  1646. ============
  1647. W_Attack
  1648.  
  1649. An attack impulse can be triggered now
  1650. ============
  1651. */
  1652. void()    player_axe1;
  1653. void()    player_axeb1;
  1654. void()    player_axec1;
  1655. void()    player_axed1;
  1656. void()    player_shot1;
  1657. void()    player_nail1;
  1658. void()    player_light1;
  1659. void()    player_rocket1;
  1660. //hip
  1661. //MED
  1662. void()   player_laser1;
  1663. void()   player_hammer1;
  1664. void()   player_mjolnir1;
  1665. //hip
  1666.  
  1667. void() W_Attack =
  1668. {
  1669.     local    float    r;
  1670.  
  1671.     if (!W_CheckNoAmmo ())
  1672.         return;
  1673.  
  1674.     makevectors    (self.v_angle);            // calculate forward angle for velocity
  1675.     self.show_hostile = time + 1;    // wake monsters up
  1676.  
  1677.     if (self.weapon == IT_AXE)
  1678.     {
  1679.         self.attack_finished = time + 0.5;
  1680.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1681.         r = random();
  1682.         if (r < 0.25)
  1683.             player_axe1 ();
  1684.         else if (r<0.5)
  1685.             player_axeb1 ();
  1686.         else if (r<0.75)
  1687.             player_axec1 ();
  1688.         else
  1689.             player_axed1 ();
  1690.     }
  1691.     else if (self.weapon == IT_SHOTGUN)
  1692.     {
  1693.         player_shot1 ();
  1694.         self.attack_finished = time + 0.5;
  1695.         W_FireShotgun ();
  1696.     }
  1697.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1698.     {
  1699.         player_shot1 ();
  1700.         self.attack_finished = time + 0.7;
  1701.         W_FireSuperShotgun ();
  1702.     }
  1703.     else if (self.weapon == IT_NAILGUN)
  1704.     {
  1705.         player_nail1 ();
  1706.     }
  1707.     else if (self.weapon == IT_SUPER_NAILGUN)
  1708.     {
  1709.         player_nail1 ();
  1710.     }
  1711.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1712.     {
  1713.         player_rocket1();
  1714.         self.attack_finished = time + 0.6;
  1715.         W_FireGrenade();
  1716.     }
  1717.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1718.     {
  1719.         player_rocket1();
  1720.         self.attack_finished = time + 0.8;
  1721.         W_FireRocket();
  1722.     }
  1723.     else if (self.weapon == IT_LIGHTNING)
  1724.     {
  1725.         self.attack_finished = time + 0.1;
  1726.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1727.         player_light1();
  1728.     }
  1729. //hip
  1730. //MED
  1731.    else if (self.weapon == IT_LASER_CANNON)
  1732.    {
  1733.       player_laser1();
  1734.    }
  1735. //MED
  1736.    else if (self.weapon == IT_MJOLNIR)
  1737.    {
  1738.       if (self.ammo_cells < 30)
  1739.          player_hammer1();
  1740.       else
  1741.          player_mjolnir1();
  1742.       self.attack_finished = time + 0.8;
  1743.    }
  1744. //MED
  1745.    else if (self.weapon == IT_PROXIMITY_GUN)
  1746.    {
  1747.       player_rocket1();
  1748.       W_FireProximityGrenade();
  1749.       self.attack_finished = time + 0.6;
  1750.    }
  1751. //hip
  1752. };
  1753.  
  1754. /*
  1755. ============
  1756. W_ChangeWeapon
  1757.  
  1758. ============
  1759. */
  1760. //hip
  1761. //MED 10/18/96 added hipweapons
  1762. //hip
  1763. void() W_ChangeWeapon =
  1764. {
  1765.     local    float    it, am, fl;
  1766. //hip
  1767.    local float oldimpulse;
  1768. //hip
  1769.     
  1770.     it = self.items;
  1771.     am = 0;
  1772.     
  1773.     if (self.impulse == 1)
  1774.     {
  1775.         fl = IT_AXE;
  1776.     }
  1777.     else if (self.impulse == 2)
  1778.     {
  1779.         fl = IT_SHOTGUN;
  1780.         if (self.ammo_shells < 1)
  1781.             am = 1;
  1782.     }
  1783.     else if (self.impulse == 3)
  1784.     {
  1785.         fl = IT_SUPER_SHOTGUN;
  1786.         if (self.ammo_shells < 2)
  1787.             am = 1;
  1788.     }        
  1789.     else if (self.impulse == 4)
  1790.     {
  1791.         fl = IT_NAILGUN;
  1792.         if (self.ammo_nails < 1)
  1793.             am = 1;
  1794.     }
  1795.     else if (self.impulse == 5)
  1796.     {
  1797.         fl = IT_SUPER_NAILGUN;
  1798.         if (self.ammo_nails < 2)
  1799.             am = 1;
  1800.     }
  1801.     else if (self.impulse == 6)
  1802.     {
  1803. //hip
  1804. if (self.weapon == IT_GRENADE_LAUNCHER)
  1805.          {
  1806.          fl = IT_PROXIMITY_GUN;
  1807.          }
  1808.       else
  1809.          {
  1810.          fl = IT_GRENADE_LAUNCHER;
  1811.          }
  1812. //    fl = IT_GRENADE_LAUNCHER;
  1813. //hip
  1814.         if (self.ammo_rockets < 1)
  1815.             am = 1;
  1816.     }
  1817.     else if (self.impulse == 7)
  1818.     {
  1819.         fl = IT_ROCKET_LAUNCHER;
  1820.         if (self.ammo_rockets < 1)
  1821.             am = 1;
  1822.     }
  1823.     else if (self.impulse == 8)
  1824.     {
  1825.         fl = IT_LIGHTNING;
  1826.         if (self.ammo_cells < 1)
  1827.             am = 1;
  1828.     }
  1829. //hip
  1830.    else if (self.impulse == 225)
  1831.     {
  1832.       fl = IT_LASER_CANNON;
  1833.       if (self.ammo_cells < 1)
  1834.          am = 1;
  1835.    }
  1836.    else if (self.impulse == 226)
  1837.     {
  1838.       fl = IT_MJOLNIR;
  1839.    }
  1840.  
  1841. //MED
  1842.    oldimpulse = self.impulse;
  1843. //hip
  1844.     self.impulse = 0;
  1845.     
  1846.     if (!(self.items & fl))
  1847.     {    // don't have the weapon or the ammo
  1848. //hip
  1849. //MED
  1850.       if (fl == IT_GRENADE_LAUNCHER)
  1851.          {
  1852.          fl = IT_PROXIMITY_GUN;
  1853.            if (!(self.items & fl)) {
  1854. //hip
  1855.         sprint (self, PRINT_HIGH, "no weapon.\n");
  1856.         return;
  1857.         }
  1858. //hip
  1859.         } }
  1860. //hip
  1861.     if (am)
  1862.     {    // don't have the ammo
  1863.         sprint (self, PRINT_HIGH, "not enough ammo.\n");
  1864.         return;
  1865.     }
  1866.  
  1867. //
  1868. // set weapon, set ammo
  1869. //
  1870.     self.weapon = fl;        
  1871.         W_SetCurrentAmmo ();
  1872.  
  1873. };
  1874. /*
  1875. ============
  1876. CheatCommand
  1877. ============
  1878. */
  1879. void() CheatCommand =
  1880. {
  1881. //      if (deathmatch)
  1882.         return;
  1883.  
  1884.     self.ammo_rockets = 100;
  1885.     self.ammo_nails = 200;
  1886.     self.ammo_shells = 100;
  1887.     self.items = self.items | 
  1888.         IT_AXE |
  1889.         IT_SHOTGUN |
  1890.         IT_SUPER_SHOTGUN |
  1891.         IT_NAILGUN |
  1892.         IT_SUPER_NAILGUN |
  1893.         IT_GRENADE_LAUNCHER |
  1894.         IT_ROCKET_LAUNCHER |
  1895.         IT_KEY1 | IT_KEY2;
  1896.  
  1897.     self.ammo_cells = 200;
  1898.     self.items = self.items | IT_LIGHTNING;
  1899.  
  1900. //hip
  1901. //MED
  1902.    self.items = self.items | IT_LASER_CANNON;
  1903.    self.items = self.items | IT_MJOLNIR;
  1904.    self.items = self.items | IT_PROXIMITY_GUN;
  1905. //hip
  1906.  
  1907.     self.weapon = IT_MJOLNIR;
  1908.     self.impulse = 0;
  1909.     W_SetCurrentAmmo ();
  1910. };
  1911.  
  1912. /*
  1913. ============
  1914. CycleWeaponCommand
  1915.  
  1916. Go to the next weapon with ammo
  1917. ============
  1918. */
  1919. void() CycleWeaponCommand =
  1920. {
  1921.     local    float    it, am;
  1922.     
  1923.     it = self.items;
  1924.     self.impulse = 0;
  1925.     
  1926.     while (1)
  1927.     {
  1928.         am = 0;
  1929. //hip
  1930.         //MED
  1931.              if (self.weapon == IT_MJOLNIR)
  1932.         {
  1933.             self.weapon = IT_AXE;
  1934.         }
  1935. //hip
  1936.         else if (self.weapon == IT_AXE)
  1937.         {
  1938.             self.weapon = IT_SHOTGUN;
  1939.             if (self.ammo_shells < 1)
  1940.                 am = 1;
  1941.         }
  1942.         else if (self.weapon == IT_SHOTGUN)
  1943.         {
  1944.             self.weapon = IT_SUPER_SHOTGUN;
  1945.             if (self.ammo_shells < 2)
  1946.                 am = 1;
  1947.         }        
  1948.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1949.         {
  1950.             self.weapon = IT_NAILGUN;
  1951.             if (self.ammo_nails < 1)
  1952.                 am = 1;
  1953.         }
  1954.         else if (self.weapon == IT_NAILGUN)
  1955.         {
  1956.             self.weapon = IT_SUPER_NAILGUN;
  1957.             if (self.ammo_nails < 2)
  1958.                 am = 1;
  1959.         }
  1960.         else if (self.weapon == IT_SUPER_NAILGUN)
  1961.         {
  1962.             self.weapon = IT_GRENADE_LAUNCHER;
  1963.             if (self.ammo_rockets < 1)
  1964.                 am = 1;
  1965.         }
  1966. //hip
  1967. //MED
  1968.       else if (self.weapon == IT_GRENADE_LAUNCHER)
  1969.         {
  1970.          self.weapon = IT_PROXIMITY_GUN;
  1971.             if (self.ammo_rockets < 1)
  1972.                 am = 1;
  1973.         }
  1974. //MED
  1975.       else if (self.weapon == IT_PROXIMITY_GUN)
  1976.         {
  1977.             self.weapon = IT_ROCKET_LAUNCHER;
  1978.             if (self.ammo_rockets < 1)
  1979.                 am = 1;
  1980.         }
  1981. //hip
  1982.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1983.         {
  1984.             self.weapon = IT_LIGHTNING;
  1985.             if (self.ammo_cells < 1)
  1986.                 am = 1;
  1987.         }
  1988. //hip
  1989. else if (self.weapon == IT_LIGHTNING)
  1990.         {
  1991.          self.weapon = IT_LASER_CANNON;
  1992.          if (self.ammo_cells < 1)
  1993.                 am = 1;
  1994.         }
  1995.       else if (self.weapon == IT_LASER_CANNON)
  1996.         {
  1997.          self.weapon = IT_MJOLNIR;
  1998.         }
  1999. //hip
  2000.         if ( (self.items & self.weapon) && am == 0)
  2001.         {
  2002.             W_SetCurrentAmmo ();
  2003.             return;
  2004.         }
  2005.     }
  2006.  
  2007. };
  2008.  
  2009.  
  2010. /*
  2011. ============
  2012. CycleWeaponReverseCommand
  2013.  
  2014. Go to the prev weapon with ammo
  2015. ============
  2016. */
  2017. void() CycleWeaponReverseCommand =
  2018. {
  2019.     local    float    it, am;
  2020.     
  2021.     it = self.items;
  2022.     self.impulse = 0;
  2023.  
  2024.     while (1)
  2025.     {
  2026.         am = 0;
  2027. //hip
  2028. //MED
  2029.       if (self.weapon == IT_MJOLNIR)
  2030.         {
  2031.          self.weapon = IT_LASER_CANNON;
  2032.          if (self.ammo_cells < 1)
  2033.                 am = 1;
  2034.         }
  2035. //MED
  2036.       else if (self.weapon == IT_LASER_CANNON)
  2037.         {
  2038.          self.weapon = IT_LIGHTNING;
  2039.          if (self.ammo_cells < 1)
  2040.                 am = 1;
  2041.         }
  2042. //hip
  2043.         if (self.weapon == IT_LIGHTNING)
  2044.         {
  2045.             self.weapon = IT_ROCKET_LAUNCHER;
  2046.             if (self.ammo_rockets < 1)
  2047.                 am = 1;
  2048.         }
  2049. //hip
  2050.       else if (self.weapon == IT_ROCKET_LAUNCHER)
  2051.         {
  2052.          self.weapon = IT_PROXIMITY_GUN;
  2053.             if (self.ammo_rockets < 1)
  2054.                 am = 1;
  2055.         }
  2056.       else if (self.weapon == IT_PROXIMITY_GUN)
  2057.         {
  2058.             self.weapon = IT_GRENADE_LAUNCHER;
  2059.             if (self.ammo_rockets < 1)
  2060.                 am = 1;
  2061.         }
  2062. //hip
  2063.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  2064.         {
  2065.             self.weapon = IT_SUPER_NAILGUN;
  2066.             if (self.ammo_nails < 2)
  2067.                 am = 1;
  2068.         }
  2069.         else if (self.weapon == IT_SUPER_NAILGUN)
  2070.         {
  2071.             self.weapon = IT_NAILGUN;
  2072.             if (self.ammo_nails < 1)
  2073.                 am = 1;
  2074.         }
  2075.         else if (self.weapon == IT_NAILGUN)
  2076.         {
  2077.             self.weapon = IT_SUPER_SHOTGUN;
  2078.             if (self.ammo_shells < 2)
  2079.                 am = 1;
  2080.         }        
  2081.         else if (self.weapon == IT_SUPER_SHOTGUN)
  2082.         {
  2083.             self.weapon = IT_SHOTGUN;
  2084.             if (self.ammo_shells < 1)
  2085.                 am = 1;
  2086.         }
  2087.         else if (self.weapon == IT_SHOTGUN)
  2088.         {
  2089.             self.weapon = IT_AXE;
  2090.         }
  2091. //hip
  2092.         else if (self.weapon == IT_AXE)
  2093.         {
  2094.          self.weapon = IT_MJOLNIR;
  2095.         }
  2096. //hip
  2097.     
  2098.         if ( (it & self.weapon) && am == 0)
  2099.         {
  2100.             W_SetCurrentAmmo ();
  2101.             return;
  2102.         }
  2103.     }
  2104.  
  2105. };
  2106.  
  2107.  
  2108. /*
  2109. ============
  2110. ServerflagsCommand
  2111.  
  2112. Just for development
  2113. ============
  2114. */
  2115. void() ServerflagsCommand =
  2116. {
  2117.     serverflags = serverflags * 2 + 1;
  2118. };
  2119.  
  2120. //hip
  2121.  
  2122. void() QuadCheat =
  2123. {
  2124.         if (deathmatch)
  2125.         return;
  2126.     self.super_time = 1;
  2127.     self.super_damage_finished = time + 30;
  2128.     self.items = self.items | IT_QUAD;
  2129.    bprint (PRINT_HIGH, "quad cheat\n");
  2130. };
  2131.  
  2132. //MED
  2133. void() WetsuitCheat =
  2134.     {
  2135.    if (deathmatch)
  2136.         return;
  2137.    self.items2 = self.items2 | HIP_IT_WETSUIT;
  2138.     self.wetsuit_time = 1;
  2139.     self.wetsuit_finished = time + 30;
  2140.    bprint(PRINT_HIGH, "wetsuit cheat\n" );
  2141.     };
  2142.  
  2143. //MED
  2144. void() EmpathyShieldsCheat =
  2145.     {
  2146.    if (deathmatch)
  2147.         return;
  2148.    self.items2 = self.items2 | HIP_IT_EMPATHY_SHIELDS;
  2149.    self.empathy_time = 1;
  2150.    self.empathy_finished = time + 30;
  2151.    bprint(PRINT_HIGH, "empathy shields cheat\n" );
  2152.     };
  2153.  
  2154. void() DumpEntities =
  2155.    {
  2156.    local entity   head;
  2157.    local float i;
  2158.  
  2159.    i = 1;
  2160.    head = nextent(world);
  2161.    while (head!=world)
  2162.       {
  2163.       dprint(ftos(i));
  2164.       dprint(" ");
  2165.       dprint(head.classname);
  2166.       dprint("\n");
  2167.       head = nextent(head);
  2168.       i = i + 1;
  2169.       }
  2170.    };
  2171.  
  2172. void() DumpLiveEntities =
  2173.    {
  2174.    local entity   head;
  2175.    local float i;
  2176.  
  2177.    i = 1;
  2178.    head = nextent(world);
  2179.    while (head!=world)
  2180.       {
  2181.       if (head.health > 0)
  2182.          {
  2183.          dprint(ftos(i));
  2184.          dprint(" ");
  2185.          dprint(head.classname);
  2186.          dprint(" ");
  2187.          dprint(vtos(head.origin));
  2188.          dprint("\n");
  2189.          dprint("--------------------\n");
  2190.          }
  2191.       head = nextent(head);
  2192.       i = i + 1;
  2193.       }
  2194.    };
  2195.  
  2196. void() Genocide =
  2197.    {
  2198.    local entity   head;
  2199.  
  2200.    if (deathmatch)
  2201.         return;
  2202.    bprint(PRINT_HIGH,"Genocide!\n");
  2203.    head = nextent(world);
  2204.    while (head!=world)
  2205.       {
  2206.       if ((head.health > 0) && (head.flags & FL_MONSTER))
  2207.          {
  2208.          T_Damage(head,world,world,head.health+10);
  2209.          }
  2210.       head = nextent(head);
  2211.       }
  2212.    };
  2213.  
  2214. float dump_coord;
  2215. void () ToggleDump =
  2216.    {
  2217.    dump_coord = 1 - dump_coord;
  2218.    if (dump_coord == 1)
  2219.       bprint(PRINT_HIGH,"Dumping Player Location\n");
  2220.    };
  2221. void () DumpCoordinates =
  2222.    {
  2223.    local entity pl;
  2224.    pl = checkclient();
  2225.    if (pl)
  2226.       {
  2227.       bprint(PRINT_HIGH,"Player: ");
  2228.       bprint(PRINT_HIGH,vtos(pl.origin));
  2229.       bprint(PRINT_HIGH,"\n");
  2230.       }
  2231.    };
  2232. //hip
  2233.  
  2234. /*
  2235. ============
  2236. ImpulseCommands
  2237.  
  2238. ============
  2239. */
  2240. void() ImpulseCommands =
  2241. {
  2242.     if (self.impulse >= 1 && self.impulse <= 8)
  2243.         W_ChangeWeapon ();
  2244. //hip
  2245.    if (self.impulse >= 225 && self.impulse <= 226)
  2246.         W_ChangeWeapon ();
  2247. //hip
  2248.     if (self.impulse == 9)
  2249.         CheatCommand ();
  2250.     if (self.impulse == 10)
  2251.         CycleWeaponCommand ();
  2252.     if (self.impulse == 11)
  2253.         ServerflagsCommand ();
  2254.     if (self.impulse == 12)
  2255.         CycleWeaponReverseCommand ();
  2256. //hip
  2257. //JIM
  2258.     if ( self.impulse == 200 )
  2259.         WetsuitCheat();
  2260. //MED
  2261.    if ( self.impulse == 201 )
  2262.       EmpathyShieldsCheat();
  2263.    if ( self.impulse == 205 )
  2264.       Genocide();
  2265.    if ( self.impulse == 206 )
  2266.       ToggleDump();
  2267.    if ( self.impulse == 202 )
  2268.       DumpEntities();
  2269.    if ( self.impulse == 203 )
  2270.       DumpLiveEntities();
  2271.    if (self.impulse == 255)
  2272.         QuadCheat ();
  2273.    if (dump_coord == 1)
  2274.       DumpCoordinates();
  2275. //hip
  2276.     self.impulse = 0;
  2277. };
  2278.  
  2279. /*
  2280. ============
  2281. W_WeaponFrame
  2282.  
  2283. Called every frame so impulse events can be handled as well as possible
  2284. ============
  2285. */
  2286. void() W_WeaponFrame =
  2287. {
  2288.     if (time < self.attack_finished)
  2289.         return;
  2290.  
  2291.     ImpulseCommands ();
  2292.     
  2293. // check for attack
  2294.     if (self.button0)
  2295.     {
  2296.         SuperDamageSound ();
  2297.         W_Attack ();
  2298.     }
  2299. };
  2300.  
  2301. /*
  2302. ========
  2303. SuperDamageSound
  2304.  
  2305. Plays sound if needed
  2306. ========
  2307. */
  2308. void() SuperDamageSound =
  2309. {
  2310.     if (self.super_damage_finished > time)
  2311.     {
  2312.         if (self.super_sound < time)
  2313.         {
  2314.             self.super_sound = time + 1;
  2315.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  2316.         }
  2317.     }
  2318.     return;
  2319. };
  2320.  
  2321.  
  2322.